package slstone.user.login.dao;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;

import slstone.user.login.dao.pojo.User;
import slstone.user.login.vo.LogInVO;

public class LogInDao
{
	
	
	//사용자 검색
	public List<User> retrieveUser(LogInVO logInVO)
	{
		String userId = logInVO.getUserId();
		
		//사용자조회 쿼리
		String hql = "from User usr " + "\n"
				   + "where usr.userId= ?";
		
		
		//DB세션
		Configuration config = new Configuration();
		SessionFactory sessionFactory = config.configure().buildSessionFactory();
		Session session = sessionFactory.openSession();
		session.beginTransaction();
		
		Query query = session.createQuery(hql);
		
		//검색조건설정
		query.setString(0, userId);
		
		//리턴값
		List<User> list = query.list();
			
		session.close(); // 关闭
		sessionFactory.close();//关闭		
		
		return list;
		
	}
	
}
